/*
 * RouterHandler.h
 *
 *  Created on: 2013. 8. 5.
 *      Author: jjaehuny
 */

#ifndef ROUTERHANDLER_H_
#define ROUTERHANDLER_H_

#include <Logger/Log.h>
#include "../idl/Location.h"

namespace CacheServer {
/*
class RouterHandler : public Router::Handler
{
	virtual void OnConnect(const Router::Address& addr)
	{
		LOG(DEV, "register Address(service_name:", addr.service_name, ")");
	}
	virtual void OnRecvMsg(const Address& from, int msg_seq, int tag_id, const char* buf, int transferred_bytes)
	{
		LOG(DEV, "Address{service_name:", from.service_name, ", id:", from.id, "}, msg_seq:", msg_seq, ", buf:", buf, ", len:", transferred_bytes);

		switch(tag_id)
		{
		case UserInfoSyn::MSG_ID :
			{
				UserInfoSyn req;
				size_t recv_bytes = transferred_bytes;
				if(false == req.Load(&buf, recv_bytes))
				{
					LOG(ERR, "MsgCliSvr_RegisterUser_Req Load Fail");
					return;
				}

//				int mod = syn.seq % s_Mode;
//				MAP & clsMap = s_clsTreeVector[mod];
//				MAP::iterator itr = clsMap.find(syn.seq);
//				if (clsMap.end() == itr)
//				{
//					LOG(DEV, "OnGetUserInfoSyn not found user userkey : ", syn.seq );
//
//					std::shared_ptr<User> clsuser = ::CacheServer::s_clsuserpool.Create();
//					clsMap[syn.seq] = clsuser;
//
//					Database::ResultSet res = Database::Execute(1, "call sp_userinfo(", syn.seq, ")");
//					if (0 != res.GetSQLError())
//					{
//						LOG(DEV, "OnUserInfoSyn errno : ", errno );
//						SendFailUserInfo(pchannelserver, syn.seq, errno, "sql error");
//						return;
//					}
//
//					if (res.end() == res.begin())
//					{
//						LOG(DEV, "OnUserInfoSyn result is null" );
//						SendFailUserInfo(pchannelserver, syn.seq, -2, "result set is zero");
//						return;
//					}
//
//
//					int idx = 1;
//					int slotIndex = 0;
//					for(Database::ResultSet::iterator itr = res.begin(); itr != res.end(); itr++)
//					{
//						int seq = itr->getInt(idx++);
//						int user_seq = itr->getInt(idx++);
//
//						for (int i = 0; i < 8; i++)
//						{
//							slot clsSlot;
//							clsSlot.open = itr->getBoolean(idx++);
//							clsSlot.seq = itr->getInt(idx++);
//							clsSlot.classtype = itr->getInt(idx++);
//							clsSlot.level = itr->getInt(idx++);
//							clsSlot.reg_date = itr->getString(idx++);
//
//							clsuser->GetUserInfo().array_Slot[slotIndex] = clsSlot;
//							slotIndex++;
//
//							User::Character clsCharacter;
//							clsCharacter._bOpen = clsSlot.open;
//							clsCharacter._char_seq = clsSlot.seq;
//							clsuser->_char_tree[clsCharacter._char_seq] = clsCharacter;
//						}
//
//						clsuser->GetUserInfo().zen = itr->getInt(idx++);
//						clsuser->GetUserInfo().main_slot_seq = itr->getInt(idx++);
//						clsuser->GetUserInfo().nickname = itr->getString(idx++);
//						clsuser->GetUserInfo().profile_url = itr->getString(idx++);
//						clsuser->GetUserInfo().score = itr->getInt(idx++);
//						clsuser->GetUserInfo().heart_blocked = itr->getInt(idx++);
//						clsuser->GetUserInfo().invite_blocked = itr->getInt(idx++);
//						clsuser->GetUserInfo().profile_opened = itr->getInt(idx++);
//
//					}
//				}
//
//				LOG(DEV, "OnUserInfoSyn found user seq : ", syn.seq );
//				std::shared_ptr<User> clsuser = (* itr).second;
//
//				UserInfoAck ack;
//				ack.seq = syn.seq;
//				ack.result = 1;
//				ack.stUserInfo = clsuser->GetUserInfo();
//
//				pchannelserver->SendMsg(ack);
//
//				clsuser->KillTimer();
			}
			break;
		case CharacterInfoSyn::MSG_ID :
			//OnRecv_UnregisterUser_Req(from, msg_seq, buf, transferred_bytes);
			break;
		case FlushCharacterInfoSyn::MSG_ID :
			//OnRecv_UnregisterUser_Req(from, msg_seq, buf, transferred_bytes);
			break;
		case FlushUserInfoSyn::MSG_ID :
			//OnRecv_UnregisterUser_Req(from, msg_seq, buf, transferred_bytes);
			break;
		case FlushUserSlotInfoSyn::MSG_ID :
			//OnRecv_UnregisterUser_Req(from, msg_seq, buf, transferred_bytes);
			break;
		case RemoveUser::MSG_ID :
			//OnRecv_UnregisterUser_Req(from, msg_seq, buf, transferred_bytes);
			break;
		default :
			LOG(ERR, "undefined command_id:", tag_id, ")");
			break;
		};
	}
	virtual void OnClose(const Router::Address& addr)
	{
		LOG(DEV, "terminate Address(service_name:", addr.service_name, ", id:", addr.id, ", type:", addr.cast_type, ")");
	}
};
*/
} /* namespace cacheserver */

#endif /* ROUTERHANDLER_H_ */
